package com.tjetc.controller;

import com.tjetc.entity.Ads;
import com.tjetc.entity.FriendLinks;
import com.tjetc.service.AdsService;
import com.tjetc.util.R;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 广告(Ads)表控制层
 *
 * @author makejava
 * @since 2025-09-15 14:10:30
 */
@RestController
@RequestMapping("/advertise")
public class AdsController {
    /**
     * 服务对象
     */
    @Resource
    private AdsService adsService;


    /**
     * 分页查询
     *
     * @param friendLinks 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping("/page")
    public R queryByPage(String name, Integer pageNum, Integer pageSize) {
        return R.ok(this.adsService.queryByPage(name,pageNum,pageSize));
    }

    /**
     * 新增数据
     *
     * @param friendLinks 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public R add(@RequestBody Ads ads) {
        adsService.insert(ads);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/delete")
    public R deleteById(Long id) {
        adsService.deleteById(id);
        return R.ok();
    }

}

